package com.origin.chaos.security.util;

import lombok.extern.slf4j.Slf4j;

import java.util.Random;

/**
 * 验证码工具类
 *
 * @author: tao.ding
 * @date 2021-07-19
 */
@Slf4j
public class CodeUtil {

    /**
     * 生成长度为len的随机数字验证码
     *
     * @param len 验证码长度
     * @return 返回生成的验证码
     */
    public static String randomIntCode(int len) {
        StringBuilder b = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < len; i++) {
            b.append(random.nextInt(10));
        }
        return b.toString();
    }

}